#include "frmsubjects.h"
#include "ui_frmsubjects.h"

FrmSubjects::FrmSubjects(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FrmSubjects)
{
    ui->setupUi(this);
    this->initForm();
}

FrmSubjects::~FrmSubjects()
{
    delete ui;
}

void FrmSubjects::initForm()
{
    QStandardItemModel *model=new QStandardItemModel(3,3,this);

    int row=0;
    QList<SubjectModel> lst=QTECHSchedDataHelper::getSubjects();
    foreach (SubjectModel m, lst) {
        model->setItem(row,0,new QStandardItem(m.getName()));
        model->setItem(row,1,new QStandardItem(QString("%1").arg(m.getTecherCount())));
        model->setItem(row,2,new QStandardItem(m.getIntro()));
        row++;
    }

    ui->tableView->setModel(model);
    ui->tableView->setColumnWidth(0,150);
    ui->tableView->setColumnWidth(1,100);
    ui->tableView->horizontalHeader()->setStretchLastSection(true);
}
